package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.domain.ncc.NccBasicSkuAttribute;
import com.bzkj.basicinfo.domain.ncc.dto.NccBasicSkuInfoDto;
import com.bzkj.basicinfo.service.ncc.NccBasicSkuAttributeService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：swj
 * @Desc
 * @Date：2025/6/26 13:04
 */
@Api(tags = "商品信息")
@RestController
@RequestMapping("/ncc/basic/skuAttribute")
public class NccBasicSkuAttributeController extends BaseController {
    @Autowired
    private NccBasicSkuAttributeService attributeService;

    /**
     * 根据条件查询ncc商品信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 16:24:47
     * @Param dto
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBasicSkuAttributeData")
    public TableDataInfo findNccBasicSkuAttributeData(NccBasicSkuInfoDto dto) {
        startPage();
        return getDataTable(attributeService.findNccBasicSkuAttributeData(dto));
    }

    /**
     * 根据id修改ncc物料属性信息
     *
     * @Author wangzhichao
     * @Date 2024/12/11 13:19:44
     * @Param entity
     */
    @ApiOperation("修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:edit')")
    @PutMapping("nccBasicSkuAttributeUpdate")
    @LogC(title = "ncc物料属性", businessType = BusinessType.UPDATE,
            tableNames = "ncc_basic_sku_attribute", pkFieldNames = "id", content = "' 物料属性名称：'+#entity.name")
    public AjaxResult nccBasicSkuAttributeUpdate(@RequestBody NccBasicSkuAttribute entity) {
        return attributeService.updateNccBasicSkuAttribute(entity);
    }

    /**
     * 修改状态
     *
     * @Author wangzhichao
     * @Date 2024/12/11 13:19:44
     * @Param entity
     */
    @ApiOperation("状态修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:edit')")
    @PutMapping("nccBasicSkuAttributeUpdateState")
    @LogC(title = "ncc物料属性状态修改", businessType = BusinessType.UPDATE,
            tableNames = "ncc_basic_sku_attribute", pkFieldNames = "id")
    public AjaxResult nccBasicSkuAttributeUpdateState(@RequestParam Integer id, @RequestParam String status) {
        return attributeService.updateState(id, status);
    }
}
